package cn.tips.dmp.biz.talent.wxApplet.controller;

import cn.tips.dmp.biz.talent.wxApplet.service.WxCheckUserService;
import cn.tips.dmp.biz.talent.wxApplet.service.WxWebService;
import cn.tips.dmp.common.constant.SystemAssistConstant;
import cn.tips.dmp.supports.result.ApiResultDTO;
import cn.tips.dmp.supports.result.ApiResultGenerator;
import cn.tips.dmp.supports.util.AESUtil;
import cn.tips.dmp.system.user.dto.SystemUserDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author pkb
 */
@RestController
@RequestMapping("/tipsApi/wechat/infoCard")
public class WxInfoCardController {

	@Autowired
	WxWebService wxWebService;

	@Autowired
	WxCheckUserService wxCheckUserService;


	/**
	 * 小程序专家名片  专家领取名片
	 */
	@PostMapping("/addUser")
	public ApiResultDTO addUser(@RequestBody SystemUserDTO systemUserDTO) {
		ApiResultDTO apiResultDto;
		try {
			systemUserDTO.setTerminal(SystemAssistConstant.systemAssistTerminal.WECHAT);
			systemUserDTO.setPassword(AESUtil.encryptPassword(AESUtil.DEFAULT_PASSWORD));
			wxWebService.addWxUser(systemUserDTO);
			apiResultDto = ApiResultGenerator.create("0", "专家领取名片新增成功!");
		} catch (Exception e) {
			e.printStackTrace();
			apiResultDto = ApiResultGenerator.create("-1", "专家领取名片新增失败!");
		}
		return apiResultDto;
	}

}
